/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.p10.miage.gestionnote.model;

import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

public class ControleValidateur {

    private String label;
    private float coefficient;
    //private int type;
    private int echelle;

    
    public ControleValidateur(String label, float coefficient/*, int type*/, int echelle) {
        this.label = label;
        this.coefficient = coefficient;
        //this.type = type;
        this.echelle = echelle;
    }

    public boolean validate(ActionMessages errors) {
        boolean valider = true;

        if (this.label == null || this.label.length() < 1) {
            valider = false;
            errors.add("label", new ActionMessage("errors.label", " Label"));
        }if (String.valueOf(this.coefficient).isEmpty() || this.coefficient < 0) {
            errors.add("coefficient", new ActionMessage("errors.coefficient", " Coefficient"));
            valider = false;
        }if (String.valueOf(this.echelle).isEmpty() || this.echelle < 1) {
            errors.add("echelle", new ActionMessage("errors.echelle", " Echelle"));
            valider = false;
        }
        
        return valider;
    }
}
